/*
* 获取请求路径和查询参数
* */
const http = require('http')
const url = require('url')

const app = http.createServer((req, res) => {
    // 第二个参数为 true 会自动解析 query
    const parseUrl = url.parse(req.url, true)

    // console.log(parseUrl)
    console.log('请求路径:', parseUrl.pathname);
    console.log('查询参数:', parseUrl.query);

    res.writeHead(200, {
        "Content-type": "text/html;charset=utf-8"
    })
    res.end('你好')
})

app.listen(3000, () => {
    console.log('Server running at http://localhost:3000/');
})